use std::str::FromStr;
pub fn convert_base(num_str: &str, to_base: u32) -> String {
    let pair: Vec<&str> = num_str.split('(').collect();
    let num = pair[0];
    let base = pair[1].trim_end_matches(')');
    
    let base_from = match u32::from_str(base) {
        Ok(val) => val,
        Err(_) => todo!(),
    };
    let mut decimal = match u32::from_str_radix(num, base_from) {
        Ok(val) => val,
        Err(_) => todo!(),
    };

    let mut ans = String::new();
    if decimal == 0 {
        return "0".to_string()
    }
    let digits = "0123456789abcdef";
    while decimal > 0 {
        let remainder = (decimal % to_base) as usize;
        ans.insert(0, digits.chars().nth(remainder).unwrap());
        decimal /= to_base;
    }
    ans
}
